package com.qianfeng;

import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class TextTime {
    @Test
    public void test(){
        Calendar instance = Calendar.getInstance();
        Calendar instance2 = Calendar.getInstance();
        Calendar instance3 = Calendar.getInstance();
        Calendar instance4 = Calendar.getInstance();
        Calendar instance5 = Calendar.getInstance();
        Calendar instance6 = Calendar.getInstance();
        Calendar instance7 = Calendar.getInstance();

        //上一周
        //今天是本周第几天
        int i = instance.get(Calendar.DAY_OF_WEEK)-1;
        System.out.println("今天是本周第几天"+i);
        //上周一
        instance.add(Calendar.DATE,-i-6);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String Monday = simpleDateFormat.format(instance.getTime());
        System.out.println("上周一"+Monday);
        //上周二
        instance2.add(Calendar.DATE,-i-5);
        String Tuesday = simpleDateFormat.format(instance2.getTime());
        System.out.println("上周二"+Tuesday);
        //上周三
        instance3.add(Calendar.DATE,-i-4);
        String Wednesday= simpleDateFormat.format(instance3.getTime());
        System.out.println("上周三"+Wednesday);
        //上周四
        instance4.add(Calendar.DATE,-i-3);
        String Thursday= simpleDateFormat.format(instance4.getTime());
        System.out.println("上周四"+Thursday);
        //上周五
        instance5.add(Calendar.DATE,-i-2);
        String Friday= simpleDateFormat.format(instance5.getTime());
        System.out.println("上周五"+Friday);
        //上周六
        instance6.add(Calendar.DATE,-i-1);
        String Saturday= simpleDateFormat.format(instance6.getTime());
        System.out.println("上周六"+Saturday);
        //上周日
        instance7.add(Calendar.DATE,-i);
        String Sunday= simpleDateFormat.format(instance7.getTime());
        System.out.println("上周日"+Sunday);

    }
}
